package good

import (
	"context"
	"fmt"
	"go-zero-mult/service/rpc/good/good"

	"go-zero-mult/service/api/internal/svc"
	"go-zero-mult/service/api/internal/types"

	"github.com/tal-tech/go-zero/core/logx"
)

type GetGoodLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewGetGoodLogic(ctx context.Context, svcCtx *svc.ServiceContext) GetGoodLogic {
	return GetGoodLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *GetGoodLogic) GetGood(req types.GoodReq) (*types.GoodResp, error) {
	// todo: add your logic here and delete this line
	GoodInfo, err := l.svcCtx.GoodRpc.GetGood(l.ctx, &good.GoodReq{
		Id: req.Id,
	})
	logx.Info("日志输出测试")

	//fmt.Printf("请求ExpandReq数据 %s...\n", req)
	fmt.Println("Good查询出来的数据")
	fmt.Println(GoodInfo)
	if err != nil {
		return nil, err
	}
	return &types.GoodResp{
		Id: GoodInfo.Id,
		GoodName: GoodInfo.GoodName,
		Desc: GoodInfo.GetDesc(),
	}, nil


	//return &types.GoodResp{}, nil
}
